package mware_lib;

/**
 * 
 * offers a local name service stub, to rebind and resolve objects
 *
 */
public class ObjectBroker {
	private NameService nameService;
	/**
	 * hostname of the remote name service
	 */
	private String hostName;
	/**
	 * port of the remote name service
	 */
	private int port;
	private static ObjectBroker obj;
	
	private ObjectBroker(String serviceHost, int listenPort) {
		this.hostName = serviceHost;
		this.port = listenPort;
		
		nameService = new NameService_Stub( hostName, port);
	}
	
	public static ObjectBroker getBroker(String serviceHost, int listenPort) { 
		if(obj == null){
			obj = new ObjectBroker(serviceHost, listenPort);
		}
		return obj;
	}
	
	

	public NameService getNameService() {
		if(nameService != null){
			return nameService;
		}else{
			return null;
		}
		
	}

}